﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AirlineSystemApp
{
    public partial class PrintTicket : Form
    {
        public string strPNRNo, strName, strSector, strFlightNo, strClass, strDate, strDepTime, strArrTime, Status;
        public PrintTicket()
        {
            InitializeComponent();
        }

        private void PrintTicket_Load(object sender, EventArgs e)
        {
            rtbTicket.BackColor = Color.White;
            rtbTicket.Text = "                                           HORIZON AIRWAYS                        ";
            rtbTicket.Text +=Environment .NewLine  + "                                              Passenger Ticket";
            rtbTicket.Text += Environment .NewLine  + "----------------------------------------------------------------------------------------------------------------";
            rtbTicket.Text += Environment .NewLine  + "                                                                                        Date of Issue: " + DateTime .Today.ToShortDateString();
            rtbTicket.Text += Environment.NewLine + "                    NOT TRANSFERABLE" + Environment.NewLine + Environment.NewLine;
            rtbTicket.Text += Environment .NewLine  + "PNR No. : " + strPNRNo + "                Passenger Name: " + strName;
            rtbTicket.Text += Environment .NewLine  + Environment .NewLine  + "Flight No: " + strFlightNo;
            rtbTicket.Text += Environment .NewLine  + Environment .NewLine  + "Class                        Travel Date            Dep.Time           Arr. Time              Status";
            rtbTicket.Text += Environment .NewLine  + "----------------------------------------------------------------------------------------------------------------";
            rtbTicket.Text += Environment .NewLine  + strClass + "                    " + strDate + "                  " + strDepTime + "           " + strArrTime + "              " + Status;
        }

        private void cmdPrint_Click(object sender, EventArgs e)
        {
            prndlgPrintTicket.Document = prndocPrintTicket;
            DialogResult result = prndlgPrintTicket.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
                prndocPrintTicket.Print();
            
            }

        private void cmdClose_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void prndocPrintTicket_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //e.Graphics.DrawString(rtbTicket.Text, new Font("MS Sans Seri", 12, FontStyle.Regular), Brushes.Black, 150, 125);
            e.Graphics.DrawString(rtbTicket.Text, new Font("Times New Roman", 12, FontStyle.Regular), Brushes.Black, 150, 125);
        }
    }
}
